package com.wordLearning.word.infra.basic.service.impl;

import com.wordLearning.word.infra.basic.dao.LearningRecordDao;
import com.wordLearning.word.infra.basic.entity.LearningRecord;
import com.wordLearning.word.infra.basic.service.LearningRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (LearningRecord)表服务实现类
 *
 * @author makejava
 * @since 2025-03-17 17:37:42
 */
@Service("learningRecordService")
public class LearningRecordServiceImpl implements LearningRecordService {
    @Resource
    private LearningRecordDao learningRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public LearningRecord queryById(Integer id) {
        return this.learningRecordDao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param learningRecord 实例对象
     * @return 实例对象
     */
    @Override
    public LearningRecord insert(LearningRecord learningRecord) {
        this.learningRecordDao.insert(learningRecord);
        return learningRecord;
    }

    /**
     * 修改数据
     *
     * @param learningRecord 实例对象
     * @return 实例对象
     */
    @Override
    public LearningRecord update(LearningRecord learningRecord) {
        this.learningRecordDao.update(learningRecord);
        return this.queryById(learningRecord.getId());
    }

    @Override
    public List<Integer> selectWordIds() {
        return this.learningRecordDao.selectAllWordIds();
    }

    @Override
    public Integer countByCondition() {
        return this.learningRecordDao.countByCondition();
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.learningRecordDao.deleteById(id) > 0;
    }
}
